package com.example.sangong.config;


import com.example.sangong.rabbitmq.RabbitMqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitQueueConfig {



    @Bean
    public DirectExchange defaultExchange() {
        return new DirectExchange(RabbitMqConstant.DEFAULT_EXCHANGE);
    }

    @Bean
    public DirectExchange notifyMsgDirectExchange() {
        return new DirectExchange(RabbitMqConstant.NOTIFY_MSG_DIRECT_EXCHANGE);
    }

    @Bean
    public Queue notifyMsgQueue() {
        return new Queue(RabbitMqConstant.NOTIFY_MSG_QUEUE);
    }


    @Bean
    public Binding notifyMsgQueueBinding() {
        return BindingBuilder
                .bind(notifyMsgQueue())
                .to(notifyMsgDirectExchange())
                .with(RabbitMqConstant.NOTIFY_MSG);
    }

}
